<?php
require_once 'application/library/helper/messageHelper.php';
require_once 'application/library/controller/gcLBasicAction.php';
require_once 'application/library/service/commService/gcProvService.php';
require_once 'application/modules/member/constant/member_constant_templatName.php';
require_once 'application/modules/member/services/member_services_memberEditService.php';

/**
 * 客户新规编辑
 * member_memberEditController
 * @author    Soochow University
 * @version   1.0
 * @exclude   作  成  日：2011/04/07
 */
class member_memberEditController extends gcLBasicAction{

    /**
     * objService
     */
    private $objService;

    /**
     * indexAction
     */
    public function indexAction(){
        $this->pvSetPageInfo();
        $this->gcView->flag = "1";
        $this->gcView->render(member_constant_templatName::MEMBER_EDIT);
    }

    /**
     * indexAction
     */
    public function editAction(){
        $arrMessageId = array(
            "INFO-00005");
        $this->setMessageForJs($arrMessageId);
        $this->pvSetPageInfo();
        $strMemberNo = $this->getParam("MemberNo");
        $this->objService=new member_services_memberEditService();
        $arrSearchData = $this->objService->pbGetMemberInfo($strMemberNo);

        $this->gcView->arrSearchData=$arrSearchData;
        $this->gcView->flag = "2";
        $this->gcView->render(member_constant_templatName::MEMBER_EDIT);
    }

    /**
     * saveAction
     */
    public function saveAction(){
        if($this->getRequest()->isXmlHttpRequest()){
            $arrParameter = array();
            $arrParameter["MemberId"] = $this->getParam("MemberId");
            $arrParameter["MemberName"] = $this->getParam("MemberName");
            $arrParameter["SaleTp"] = $this->getParam("SaleTp");
            $arrParameter["ProvCode"] = $this->getParam("ProvCode");
            $arrParameter["City"] = $this->getParam("City");
            $arrParameter["District"] = $this->getParam("District");
            $arrParameter["MemberStatus"] = $this->getParam("MemberStatus");
            $arrParameter["MemberScale"] = $this->getParam("MemberScale");
            $arrParameter["ContractNo"] = $this->getParam("ContractNo");
            $arrParameter["Tel"] = $this->getParam("Tel");
            $arrParameter["Mobile"] = $this->getParam("Mobile");
            $arrParameter["Fax"] = $this->getParam("Fax");
            $arrParameter["Email"] = $this->getParam("Email");
            $arrParameter["QQ"] = $this->getParam("QQ");
            $arrParameter["MSN"] = $this->getParam("MSN");
            $arrParameter["Ali"] = $this->getParam("Ali");
            $arrParameter["Homepage"] = $this->getParam("Homepage");
            $arrParameter["PaymentTp1"] = $this->getParam("PaymentTp1");
            $arrParameter["Account1"] = $this->getParam("Account1");
            $arrParameter["PaymentTp2"] = $this->getParam("PaymentTp2");
            $arrParameter["Account2"] = $this->getParam("Account2");
            $arrParameter["PaymentTp3"] = $this->getParam("PaymentTp3");
            $arrParameter["Account3"] = $this->getParam("Account3");
            $arrParameter["UserNo"] = userDataHelper::getLoginUserNo();
            $this->objService=new member_services_memberEditService();
            $strFlag = $this->getParam("Flag");
            if ($strFlag == "1") {
                $strReturn = $this->objService->pbInsertMemberInfo($arrParameter);
            } else {
                $arrParameter["MemberNo"] = $this->getParam("MemberNo");
                $arrParameter["DataVersion"] = $this->getParam("DataVersion");
                $strReturn = $this->objService->pbUpdateMemberInfo($arrParameter);
            }
            if ($strReturn == 0) {
                $strReturnFg = $this->getMessage("ERR-00002");
            } else {
                $strReturnFg = "2";
            }
            $arrOutput = array(
                "count"     => $strReturn,
                "ReturnFg"  => $strReturnFg);
            jsonHelper::outPutJson($arrOutput);
        }else{
            echo 2;
        }
    }

    /**
     * deleteAction
     */
    public function deleteAction(){
        if($this->getRequest()->isXmlHttpRequest()){
            
            $arrParameter = array();
            $arrParameter["MemberNo"] = $this->getParam("MemberNo");
            $arrParameter["DataVersion"] = $this->getParam("DataVersion");
            $this->objService=new member_services_memberEditService();
            $strReturn = $this->objService->pbDeletetMemberInfo($arrParameter);
            if ($strReturn == 0) {
                $strReturnFg = $this->getMessage("ERR-00003");
            } else {
                $strReturnFg = "3";
            }
            $arrOutput = array(
                "count"     => $strReturn,
                "ReturnFg"  => $strReturnFg);
            jsonHelper::outPutJson($arrOutput);
        }else{
            echo 2;
        }
    }

    /**
     * pvSetPageInfo
     */
    private function pvSetPageInfo(){
        $objProv = new gcProvService();
        $arrProv = $objProv->getProvInfo();
        $this->gcView->arrProv=$arrProv;
        $this->gcView->title                        = $this->getLabel("member_00001_Member").$this->getLabel("member_00002_Info");
        $this->gcView->member_00002_Title         = $this->getLabel("member_00001_Member").$this->getLabel("member_00002_Insert");
        $this->gcView->member_00002_Notice        = $this->getLabel("member_00002_Notice");
        $this->gcView->member_00002_Member      = $this->getLabel("member_00001_Member");
        $this->gcView->member_00002_Title2        = $this->getLabel("member_00001_Member").$this->getLabel("member_00002_Basic").$this->getLabel("member_00002_Info").$this->getLabel("member_00002_Setting");
        $this->gcView->member_00002_MemberName  = $this->getLabel("member_00001_MemberName");
        $this->gcView->member_00002_SaleTp        = $this->getLabel("member_00001_SaleTp");
        $this->gcView->member_00002_Prov          = $this->getLabel("member_00001_Prov");
        $this->gcView->member_00002_Position      = $this->getLabel("member_00001_Position");
        $this->gcView->member_00002_Example       = $this->getLabel("member_00001_Example");
        $this->gcView->member_00002_ContractNo    = $this->getLabel("member_00001_ContractNo");
        $this->gcView->member_00002_Tel           = $this->getLabel("member_00001_Tel");
        $this->gcView->member_00002_Mobile        = $this->getLabel("member_00001_Mobile");
        $this->gcView->member_00002_Fax           = $this->getLabel("member_00001_Fax");
        $this->gcView->member_00002_Email         = $this->getLabel("member_00001_Email");
        $this->gcView->member_00002_Factory       = $this->getLabel("member_00001_Factory");
        $this->gcView->member_00002_Seller        = $this->getLabel("member_00001_Seller");
        $this->gcView->member_00002_Status        = $this->getLabel("member_00001_Status");
        $this->gcView->member_00002_Trust         = $this->getLabel("member_00001_Trust");
        $this->gcView->member_00002_NoTrust       = $this->getLabel("member_00001_NoTrust");
        $this->gcView->member_00002_Scale         = $this->getLabel("member_00001_Scale");
        $this->gcView->member_00002_More          = $this->getLabel("member_00001_More");
        $this->gcView->member_00002_Less          = $this->getLabel("member_00001_Less");
        $this->gcView->member_00002_People        = $this->getLabel("member_00001_People");
        $this->gcView->member_00002_Edit          = $this->getLabel("member_00001_Edit");
        $this->gcView->member_00002_Add           = $this->getLabel("member_00001_Add");
        $this->gcView->member_00002_City          = $this->getLabel("member_00002_City");
        $this->gcView->member_00002_Address       = $this->getLabel("member_00002_Address");
        $this->gcView->member_00002_Save          = $this->getLabel("member_00002_Save");
        $this->gcView->member_00002_Delete        = $this->getLabel("member_00002_Delete");
        $this->gcView->member_00002_Ali           = $this->getLabel("member_00002_Ali");
        $this->gcView->member_00002_Homepage      = $this->getLabel("member_00002_Homepage");
        $this->gcView->member_00002_Title3        = $this->getLabel("member_00001_Member").$this->getLabel("member_00002_PaymentKind").$this->getLabel("member_00002_Setting");
        $this->gcView->member_00002_PaymentKind   = $this->getLabel("member_00002_PaymentKind");
        $this->gcView->member_00002_PaymentMethod = $this->getLabel("member_00002_PaymentMethod");
        $this->gcView->member_00002_Account       = $this->getLabel("member_00002_Account");
        $this->gcView->member_00002_NotUse        = $this->getLabel("member_00002_NotUse");
        $this->gcView->member_00002_Bank          = $this->getLabel("member_00002_Bank");
        $this->gcView->member_00002_Epay          = $this->getLabel("member_00002_Epay");
        $this->gcView->member_00002_Cash          = $this->getLabel("member_00002_Cash");
        $this->gcView->member_00002_Message1      = messageHelper::formatMessage($this->getMessage("ERR-00004"), array(13));
    }
}
